package com.xiyun.f101t200;

public class BestTimeForStocks_122 {
    class Solution {
        public int maxProfit(int[] prices) {
            int ans = 0;
            int n = prices.length;
            for (int i = 1; i < n; ++i) {
                ans += Math.max(0, prices[i] - prices[i - 1]);
            }
            return ans;
        }
    }

    public static void resolve(String[] args) {
//          1 <= prices.length <= 3 * 104
//          0 <= prices[i] <= 104
        int prices[] = {7,1,5,3,6,4};
        BestTimeForStocks_122.Solution solution = new BestTimeForStocks_122().new Solution();
        solution.maxProfit(prices);
    }
}
/*执行用时：1 ms, 在所有 Java 提交中击败了81.32%的用户
内存消耗：41.7 MB, 在所有 Java 提交中击败了5.09%的用户*/
